<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="container-div">
	<div class="col-sm-12 select-info">
				<form id="post-form">
					<div class="select-list">
						<ul>
							<li class="select-time">
								<label>时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								职工姓名：<input type="text" name="userName"/>
							</li>
							<li>
								餐别：<select name="dinnerType" th:with="type=${@dict.getType('dinner_type')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							    <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()" shiro:hasPermission="system:post:export"><i class="fa fa-download"></i>&nbsp;导出</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
		<div class="btn-group hidden-xs" id="toolbar" role="group">
			<a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.removeAll()" shiro:hasPermission="system:post:remove">
	            <i class="fa fa-trash-o"></i> 删除
	        </a>
        </div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('module:book:edit')}]];
        var removeFlag = [[${@permission.hasPermi('module:book:remove')}]];
        var dinnerType = [[${@dict.getType('dinner_type')}]];
        var dinnerSign = [[${@dict.getType('dinner_sign_in')}]];
        var selfOrVisitor = [[${@dict.getType('self_or_visitor')}]];
        var isEat = [[${@dict.getType('is_eat')}]];
        var prefix = ctx + "statistic/book"

        $(function() {
            var options = {
                url: prefix + "/book",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "报餐明细",
                exportUrl: prefix + "/exportbooklist",
                search: false,
		        showExport: false,
                columns: [{
		            checkbox: true
		        },{
					field : 'bookId', 
					title : '报餐编号' 
				},{
					field : 'userName', 
					title : '姓名' 
				},
				{
					field : 'eatDate', 
					title : '就餐日期',
                    formatter: function (value) {
                        return changeDateFormat(value)
                    }
				},
				{
					field : 'dinnerType', 
					title : '餐别',
					formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(dinnerType, value);
		            }
				},
				{
					field : 'bookNum', 
					title : '报餐数量' 
				},
				{
					field : 'bookType', 
					title : '报餐类别' ,
					 formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(selfOrVisitor, value);
		            }
				},
				{
					field : 'signIn', 
					title : '是否签到' ,
					 formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(dinnerSign, value);
		            }
				},
				{
					field : 'signTime', 
					title : '签到时间' 
				},
				{
					field : 'isEat', 
					title : '是否就餐' ,
					 formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(isEat, value);
		            }
				},
				{
					field : 'dishes',
					title : '所选菜品'
				},
				{
					field : 'price',
					title : '单价'
				},
				{
					field : 'totalPrice',
					title : '金额'
				},
				{
					field : 'remark', 
					title : '备注' 
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.bookId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        function changeDateFormat(cellval) {
            if (cellval != null) {
                var d = new Date(cellval);
                var month = d.getMonth() + 1 < 10 ? "0" + (d.getMonth() + 1) : d.getMonth() + 1;
                var currentDate = d.getDate() < 10 ? "0" + d.getDate() : d.getDate();
                var times = d.getFullYear() + '-' + month + '-' + currentDate;
                return times;
            } else {
                return cellval;
            }

        }
    </script>
</body>
</html>